This invention relates generally to storage systems and more particularly to a method and apparatus for reading blocks of different sizes from a storage medium.
Traditionally, mass storage systems have been based upon magnetic media, such as floppy disks, hard drives, and tapes. In recent years, however, because of their high storage capacities, optical media have also been used effectively for mass storage purposes. Optical media include CD-ROM""s (compact disk-read only memory), recordable CD""s, and re-writable CD""s. Typically, information is written onto an optical medium by imposing marks and spaces or pits and lands onto the medium. These marks and spaces or pits and lands are later detected by a reading mechanism to extract information from the optical medium.
Typically, information is written onto a CD in the form of packets. Each packet usually comprises a certain number of data blocks, and each packet is separated from other packets by a link sequence. A typical packet arrangement is shown in FIG. 1, wherein a plurality of packets 102 are shown with link sequences 104 imposed therebetween. The link sequences 104 provide distinct separations between the data packets 102, which makes management of data on the CD much simpler.
As shown, a typical link sequence 104 comprises a series of seven blocks. These blocks include two RUNOUT blocks 106, 108, one link block 110, and four RUNIN blocks 112-118. The RUNOUT blocks 106, 108 signal the end of the previous packet, the RUNIN blocks 112-118 signal the beginning of the next packet, and the link block 110 provides the transition between the RUNOUT blocks 106, 108 and the RUNIN blocks 112-118. One of the main purposes of the link sequence blocks 106-118 is to provide sufficient xe2x80x9cpaddingxe2x80x9d to enable the writing and reading mechanisms to start and to stop gracefully.
To elaborate, when writing information onto a CD, it is often necessary to stop the writing mechanism after writing a certain packet, and then to restart the writing mechanism to write the next packet. This is especially true in recordable and rewritable CD systems. The link sequence blocks 106-118 are designed to accommodate this. Specifically, when the writing mechanism is writing the last packet of a file, it: (1) writes the last data packet; (2) writes the two RUNOUT blocks 106, 108; (3) writes a portion of the link block 110; and (4) then stops gracefully. When it comes time to write the next data packet, the writing mechanism: (1) starts gracefully; (2) completes writing the link block 110; (3) writes the RUNIN blocks 112-118; and (4) then writes the next data packet. Ideally, in completing the link block 110, the writing mechanism starts writing at precisely the point at which it previously stopped. Unfortunately, due to limitations in the current technology, this level of precision is often not possible. As a result, the writing mechanism often starts writing at a location before or after the proper location, which leads to the link block 110 being shorter or longer than the rest of the link sequence blocks 106-108, 112-118. This variation in size of the link block 110 can lead to serious problems when it comes time to read the CD.
To illustrate this problem, reference will be made to FIG. 2. FIG. 2 shows a sample set of link sequence blocks 106-118 in which the link block 110 is longer than the rest of the blocks. FIG. 2 also shows a buffer 204, having buffer portions BU1-BU8, which may be used to buffer the information contained in the link sequence blocks 106-118. Given the setup shown in FIG. 2, a typical reading mechanism operates as follows. The mechanism begins reading the link sequence blocks by reading the first RUNOUT block 106. The first portion of block 106 encountered by the reading mechanism is the SYNCH portion 202, which indicates the beginning of the block 106. In response to the SYNCH portion, the reading mechanism increments the buffer pointer to position P1, which points to the beginning of buffer portion BU1206. The mechanism then reads and stores the contents of RUNOUT block 106 into buffer portion BU1206. The first RUNOUT block 106 is thus read and buffered.
Thereafter, the reading mechanism proceeds to read the second RUNOUT block 108. Again, it encounters a SYNCH portion 202 at the beginning of the block. The contents of this SYNCH portion 202 are stored at the end of buffer portion BU1206. In response to the SYNCH portion 202, the reading mechanism increments the buffer pointer to position P2, which points to the beginning of buffer portion BU2208. The mechanism then reads and stores the contents of RUNOUT block 108 into buffer portion BU2208. The second RUNOUT block 208 is thus buffered.
Now, the reading mechanism proceeds to read the link block 110. As with the previous two blocks, it encounters a SYNCH portion 202 at the beginning of the block 110. The contents of this SYNCH portion 202 are stored at the end of buffer portion BU2208. In response to the SYNCH portion 202, the reading mechanism increments the buffer pointer to position P3. The mechanism then proceeds to read and to store the contents of the link block 110 into buffer portion BU3210. However, when the reading mechanism reaches the portion of the link block 110 indicated by the dashed line 230, the mechanism realizes that it has not detected a SYNCH portion for an N number of words, where N is the typical size of one of the blocks 106-108, 112-118. In response to this realization, the reading mechanism automatically increments the buffer pointer to position P4. Thereafter, the mechanism continues reading the remainder of the link block 110, and storing the remainder into buffer portion BU4212.
After reading the link block 110, the reading mechanism encounters the SYNCH portion 202 at the beginning of the first RUNIN block 112. This SYNCH portion 202, the contents of which are stored into buffer portion BU4212, causes the buffer pointer to be incremented to position P5. This in turn causes the remainder of buffer portion BU4212 to be left unused. Thereafter, the reading mechanism reads and stores the contents of RUNIN block 112 into buffer portion BU5214. RUNIN block 112 is thus buffered. This process of reading and buffering the link sequence blocks continues until the contents of RUININ block 114 and the SYNCH portion 202 of RUNIN block 116 are stored into buffer portion BU6216, the contents of RUININ block 116 and the SYNCH portion 202 of RUNIN block 118 are stored into buffer portion BU7218, and the contents of RUININ block 118 and the SYNCH portion 202 of the next data block are stored into buffer portion BU8220.
Notice that by the end of the buffering process, eight buffer portions BU1-BU8 are used. This is so despite the fact that in actuality only seven sequence blocks were read. The extra buffer portion resulted from the oversized link block 110 being effectively counted as two blocks. When the eight buffer portions BU1-BU8 are subsequently passed on to a host, they cause the host to erroneously believe that eight rather than seven blocks have actually been read. This over-counting of blocks may cause the host to erroneously treat a link sequence block as a data block (since the host is expecting only seven link sequence blocks, it may treat the eighth block BU8 as a data block). Over-counting may also cause the host to calculate offsets incorrectly, and to experience other serious errors. Thus, the variation in size of the link block 110 can lead to significant problems. As a result, a solution to the size variation problem is needed.
The present invention provides an improved method and apparatus for reading blocks from a storage medium, which enables blocks of different sizes to be read without causing subsequent errors to be experienced by a host. The present invention is based, at least partially, upon two observations. The first observation is that it is not necessary to increment a buffer page pointer or a page counter in response to every indication of the beginning of a new or subsequent block. The second observation is that link sequence blocks are mainly used for padding purposes and thus typically do not contain actual data. Hence, certain portions of link sequence blocks may be overwritten without doing any harm. These observations are used advantageously by the present invention to prevent block size variations from causing subsequent errors.
Specifically, the present invention implements the concept of a guardband to prevent double counting of oversized blocks. Under the guardband concept, each time an indication of the beginning of a new or subsequent block is detected, a check is made to determine whether the current word count (indicating the number of words that have been read since the last time a buffer page pointer or a block counter was incremented) is within a predetermined guardband. If it is, then it means that the buffer page pointer or the block counter was incremented just recently, meaning that the information being read is most likely the remainder of an oversized block. In such a case, the buffer page pointer or the block counter is not incremented but is rather maintained at its current value. By doing so, the present invention prevents the oversized block from being counted as two blocks, which in turn prevents subsequent errors from being experienced by a host. The fact that these values are not incremented may cause a part of a block to be overwritten in a buffer page. However, as noted above, since the link sequence blocks do not contain actual data, overwriting a portion of a block will not do any harm. Thus, the present invention effectively prevents the overcounting of blocks without causing any undesirable side effects.